package Eyjafjalla.power;

import Eyjafjalla.action.MakeTempCardInCloudAction;
import Eyjafjalla.card.skill.Songs_Eyjafjalla;
import Eyjafjalla.character.Eyjafjalla;
import Eyjafjalla.patch.MelodyPatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.megacrit.cardcrawl.actions.common.MakeTempCardInHandAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.localization.PowerStrings;

public class FluffShieldPower extends AbstractEyjafjallaPower {
    public static final String POWER_ID = "eyjafjalla:FluffShieldPower";
    private static final PowerStrings powerStrings;

    public FluffShieldPower(AbstractCreature owner){
        this.name = powerStrings.NAME;
        this.ID = POWER_ID;
        this.owner = owner;
        String path128 = "EyjafjallaResources/img/power/FluffShieldPower_84.png";
        String path48 = "EyjafjallaResources/img/power/FluffShieldPower_32.png";
        this.region128 = new TextureAtlas.AtlasRegion(ImageMaster.loadImage(path128),0,0,84,84);
        this.region48 = new TextureAtlas.AtlasRegion(ImageMaster.loadImage(path48),0,0,32,32);
        this.isTurnBased = true;
        this.type = PowerType.BUFF;
        this.updateDescription();
    }

    @Override
    public float atDamageReceive(float damage, DamageInfo.DamageType damageType) {
        if (!inMelody()&&damageType == DamageInfo.DamageType.NORMAL) {
            return damage*0.2F;
        } else {
            return damage;
        }
    }

    @Override
    public int onAttacked(DamageInfo info, int damageAmount) {
        if(!inMelody()&&info.type != DamageInfo.DamageType.NORMAL&&info.type != DamageInfo.DamageType.HP_LOSS)
            return (int) (damageAmount*0.2F);
        return damageAmount;
    }

    private boolean inMelody(){
        if(MelodyPatch.currentSingle!=null&&MelodyPatch.currentSingle.melodyName.equals(powerStrings.DESCRIPTIONS[1]))
            return true;
        return false;
    }

    @Override
    public void updateDescription() {
        this.description = powerStrings.DESCRIPTIONS[0];
    }

    static {
        powerStrings = CardCrawlGame.languagePack.getPowerStrings(POWER_ID);
    }
}





